import React, { Component } from 'react'

export default class App extends Component {
    state={
        myname: '张三',
        myage:22
    }
    static getDerivedStateFromProps(props, state){
        console.log('a',props, state)
        return {
            myname:state.myname
        }
    }
  render() {
    return (
      <div>
          <button onClick={()=>{
                    this.setState({
                        myname:"xiaoming"
                    })
                }}>click</button>
          {this.state.myname}---{this.state.myage}</div>
    )
  }
}
